
import {
	getActivity,
	getListSubject,
	getDetailSubject,
	submitVote,
	addView
} from "@/api/Home";

export default defineStore('useHome', {
	state: () => ({}),
	getters: {},
	actions: {
		// 获取
		async getActivity(params) {
			let url = $globalRequestUrl({
				url: getActivity,
			});

			try {
				const rep = await $globalRequest(url, params, { method: "GET" });
				return rep;
			} catch (error) {
				return error;
			}
		},
		// 获取
		async getListSubject(params) {
			let url = $globalRequestUrl({
				url: getListSubject,
			});
			try {
				const rep = await $globalRequest(url, params, { method: "post" });
				return rep;
			} catch (error) {
				return error;
			}
		},
		// 获取
		async getDetailSubject(params) {
			let url = $globalRequestUrl({
				url: getDetailSubject,
			});
			try {
				const rep = await $globalRequest(url, params, { method: "get" });
				return rep;
			} catch (error) {
				return error;
			}
		},
		async submitVote(params){
			let url = $globalRequestUrl({
				url: submitVote,
			});
			try {
				const rep = await $globalRequest(url, params, { method: "post" });
				return rep;
			} catch (error) {
				return error;
			}
		},
		// 阅读数 /survey/subject/addView
		async addView(params) {
			let url = $globalRequestUrl({
				url: addView || '',
			});
			try {
				const rep = await $globalRequest(url, params, { method: "get" });
				return rep;
			} catch (error) {
				return error;
			}
		}
	},
});
